<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" isErrorPage="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>试卷信息管理</title>
	<%
    	String path = request.getContextPath();
	    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path;
    %>
	<c:set var="path" value="<%=basePath %>"></c:set>
 	<link href="${path }/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
 	<link href="${path }/css/bootstrap/bootstrap-datetimepicker.min.css" rel="stylesheet" />
 	<link rel="stylesheet" type="text/css" href="${path }/js/zeroModal/zeroModal.css" />
</head>
<body>

	<div>
		<form action="examPapers" method="get">
				<div style="float:left;line-height:30px"><label class="col-sm-0 control-label">试卷名称：</label></div>
				<div class="col-sm-2" style="float:left">
					<input class="form-control" id="paperName" name="paperName" type="text" value="${paperName}" placeholder="请输入试卷名称" />
				</div>
				<div style="float:left;line-height:30px">
					<label class="col-sm-0 control-label">创建时间：</label>
				</div>
				<div class="input-group date form_datetime col-md-2" style="float:left" id="loading">
                    <input class="form-control" type="text" id="addTimeStart" name="addTimeStart" value="${addTimeStart}" placeholder="请输入开始时间" readonly="readonly"/>
                    <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
				</div>
				<div style="float:left;line-height:30px">
					-
				</div>
				<div class="input-group date form_datetime col-md-2" style="float:left">
					<input class="form-control" type="text" id="addTimeEnd" name="addTimeEnd" value="${addTimeEnd}" placeholder="请输入结束时间" readonly="readonly"/>
                    <span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
				</div>
				<button class="btn btn-primary" onclick="sub()">开始搜索</button>
		</form>
		<table class="table table-striped table-hover table-condensed">
			<thead>
				<tr>
					<th>试卷编号</th>
					<th>试卷名称</th>
					<th>题目数量</th>
					<th>总分</th>
					<th>考试时长</th>
					<th>难易程度</th>
					<th>创建者</th>
					<th>创建时间</th>
					<th>操作&nbsp;&nbsp;
						<button type="button" class="btn btn-xs btn-info" onclick="_me(0, 'examPaperedit', 'examPapers')">添加</button>
					</th>
				</tr>
			</thead>
			<tbody>
				<c:choose>
					<c:when test="${not empty map }">
						<c:forEach items="${map}" var="ep">
							<tr class="subject_info">
								<td>${ep.examPaperId}</td>
								<td>${ep.examPaperName }</td>
								<td id="examPaper-sn${ep.examPaperId }">${ep.subjectNum }</td>
								<td id="examPaper-score${ep.examPaperId }">${ep.examPaperScore }</td>
								<td>${ep.examPaperTime }</td>
								<td>
									<c:if test="${ep.examPaperEasy == 0 }">
										简单
									</c:if>
									<c:if test="${ep.examPaperEasy == 1 }">
										普通
									</c:if>
									<c:if test="${ep.examPaperEasy == 2 }">
										困难
									</c:if>
								</td>
								<td>${ep.creator }</td>
								<td>
									<fmt:formatDate value="${ep.establishTime }" pattern="yyyy-MM-dd hh:mm:ss" />
								</td> 
								<td>
									<div class="btn-group">
										<button type="button" class="btn btn-info btn-sm" onclick="_me(1, 'examPaperedit?examPaperId=${ep.examPaperId }', 'examPapers')">修改</button>
										<button type="button" class="btn btn-danger btn-sm" onclick="del('examPaperDelete/${ep.examPaperId}')">删除</button>
										<button type="button" class="btn btn-info btn-sm examPaper-subjects" id="${ep.examPaperId}">查看试题</button>
									</div>
								</td>
							</tr>
						</c:forEach>
					</c:when>
				</c:choose>
			</tbody> 
		</table>
		<form action="student" method="post">
			<input type="hidden" value="DELETE" name="_method" />
		</form>
		<c:if test="${pageTotal > 1 }">
			<div style="text-align:center">
				<ul class="pagination"> 
					<c:if test="${pageNow-1 > 0 }">
						<li><a href="examPapers?startPage=${pageNow-1 }">&laquo;</a></li>
					</c:if>
					<c:forEach begin="1" end="${pageTotal }" step="1" var="pageNo">
						<c:if test="${pageNow == pageNo }">
							<li class="active"><a href="examPapers?startPage=${pageNo }">${pageNo }</a></li>
						</c:if>
						<c:if test="${pageNow != pageNo }">
							<li><a href="examPapers?startPage=${pageNo }" class="pageLink">${pageNo }</a></li>
						</c:if>
					</c:forEach>
					<c:if test="${pageNow+1 <= pageTotal }">
						<li><a href="examPapers?startPage=${pageNow+1}">&raquo;</a></li>
					</c:if>
				</ul>
			</div>
		</c:if>
	</div>


	<!-- js引入 -->
    <script src="${path }/js/jquery.min.js"></script>
    <script src="${path }/js/jquery.js"></script>
    <script src="${path }/js/bootstrap/bootstrap.min.js"></script>
   	<script src="${path }/js/bootstrap/bootstrap-datetimepicker.min.js"></script>
    <script src="${path }/js/handle.js"></script>
    <script src="${path }/js/zeroModal/zeroModal.min.js"></script>
    <script src="${path }/js/add-update.js"></script>
   	<script src="${path }/js/view-link.js"></script>
   	
    <script>
		$('.form_datetime').datetimepicker({
	        weekStart: 0, //一周从哪一天开始
	        todayBtn:  1, //
	        autoclose: 1,
	        todayHighlight: 1,
	        startView: 2,
	        forceParse: 0,
	        showMeridian: 1
	    });
		function sub(){
			//开始搜索
			$.ajax({
				type : 'get',
				data : $('form').serialize(),
				url : "examPapers",
				success : function() {
				},
				error : function(xhr) {
					alert("数据提交失败!");
				}
			});
		}
    </script>
</body>
</html> 